<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript">
        (function (document, window) {
            var isReady = false,
                    handlerList = [];

            function fireHandlers(){
                var fn;
                while(fn=handlerList.shift()){
                    fn();
                }
            }

            var ln = {
                ready:function (callback) {
                    (function () {
                        if (!isReady) {
                            /**
                             * 没有ready的状态，在ie下利用doScroll方式进行ready判断
                             *
                             */
                            try {
                                // throws errors until after ondocumentready
                                document.documentElement.doScroll('left');
                                //saveHandlers;
                                handlerList.push(callback);
                            } catch (e) {
                                return setTimeout(arguments.callee, 50);
                            }
                            // no errors, fire
                            isReady = true;
                            fireHandlers();
                        } else {
                            /**
                             * 这个是在ready过程结束后，添加handler的情况
                             * 这种情况就不需要经过上面的判断了，直接执行handler即可
                             */
                            callback();
                        }
                    })();
                }
            };
            window.ln = ln;
        }(document, window));
        ln.ready(function () {
            //console.log('doScroll Ready---1!!!');
        });
        ln.ready(function () {
            //console.log('doScroll Ready---2!!!');
        });
        window.onload = function () {
            //console.log('window onload!')
        };
    </script>


</head>
<body>

<img src="http://www.baidu.com/img/baidu_sylogo1.gif" width="270" height="129">
<img src="http://www.planeart.cn/demo/imgZoom/_demo/b2.jpg" alt="">
<iframe src="http://www.baidu.com"></iframe>


</body>
</html>
